package com.yuwei.home.parking_space_management.car_view

import androidx.lifecycle.MutableLiveData
import androidx.lifecycle.viewModelScope
import com.yuwei.base.BaseViewModel
import com.yuwei.http.ApiService
import com.yuwei.http.entity.ParkingEntity
import dagger.hilt.android.lifecycle.HiltViewModel
import kotlinx.coroutines.launch
import javax.inject.Inject

@HiltViewModel
class ParkingViewModel @Inject constructor(
    val apiService: ApiService
):BaseViewModel() {
    val getParkingSuccess by lazy { MutableLiveData<ParkingEntity>() }
    fun getParking(areaId:Int){
        viewModelScope.launch {
            executeNetwork({
                apiService.getParking(areaId)
            },getParkingSuccess::postValue)
        }
    }
    val getDeleteParkingSuccess by lazy { MutableLiveData<String>() }
    fun getDeleteParking(id:Int){
        viewModelScope.launch{
            executeNetwork({
                apiService.getDeleteParking(id)
            },getDeleteParkingSuccess::postValue)
        }
    }
}